/**
 * Created with CLion.
 * Description: 
 * User: loong
 * Date: 2025/4/26
 * Time: 9:45
 */

#ifndef ASSETSTORE_H
#define ASSETSTORE_H
#include <SDL3/SDL.h>
#include <SDL3_image/SDL_image.h>
#include <SDL3_mixer/SDL_mixer.h>
#include <SDL3_ttf/SDL_ttf.h>
#include <unordered_map>

class AssetStore
{
public:
    explicit AssetStore(SDL_Renderer * renderer) { renderer_ = renderer; }
    ~AssetStore() = default;

    void Clean();

    // 4个载入函数
    void LoadImage(const std::string & _file_path);
    void LoadSound(const std::string & _file_path);
    void LoadMusic(const std::string & _file_path);
    void LoadFont(const std::string & _file_path, int _font_size);

    // 4个读取函数
    SDL_Texture * GetImage(const std::string & _file_path);
    Mix_Chunk *   GetSound(const std::string & _file_path);
    Mix_Music *   GetMusic(const std::string & _file_path);
    TTF_Font *    GetFont(const std::string & _file_path, int _font_size);

private:
    SDL_Renderer * renderer_ {nullptr};

    std::unordered_map<std::string, SDL_Texture *> textures_;
    std::unordered_map<std::string, Mix_Chunk *>   sounds_;
    std::unordered_map<std::string, Mix_Music *>   music_;
    std::unordered_map<std::string, TTF_Font *>    fonts_;
};

#endif//ASSETSTORE_H
